package com.gw.vip.common.enums;


import java.util.Arrays;

/**
 * @author GW
 */

public enum StatusEnums {
    /**
     * 状态码
     */
    ORIGINAL("O", "初始"),
    READY("RA", "准备完成"),
    TRANSACTION("T", "交易中"),
    SUCCESS("S", "成功"),
    NONE("N", "状态不存在"),
    UNKNOWN("U", "状态未知"),
    ERROR("E", "失败"),
    CANCEL("C", "订单关闭"),
    VERIFICATION("V", "已核销"),
    REFUND("R", "已退款"),
    FORBIDDEN("F", "被禁止");

    private String code;
    private String msg;

    StatusEnums(String code, String msg){
        this.code = code;
        this.msg = msg;
    }

    public String getCode(){
        return this.code;
    }

    public String getMsg(){
        return this.msg;
    }

    public static StatusEnums getEnum(String value){
        StatusEnums[] items= StatusEnums.values();
        return Arrays.stream(items).filter(item->item.getCode().equals(value)).findFirst().orElse(null);
    }

    public static boolean checkKey(String value){
        StatusEnums[] items= StatusEnums.values();
        for (StatusEnums item:items){
            if (item.getCode().equals(value)){
                return true;
            }
        }
        return false;
    }
}
